package com.hk.admin.module.system.dao;


import com.hk.admin.common.model.system.MenuModel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * <br>
 * <b>功能：</b><br>
 * <b>作者：</b>Pan.ShiJu<br>
 * <b>日期：</b>2017/6/19 17:10<br>
 */
public interface MenuRepository extends JpaRepository<MenuModel, Long>, JpaSpecificationExecutor<MenuModel> {

    List<MenuModel> findByDeletedOrderByRank(int key);

    List<MenuModel> findByIdIn(List<Long> menuIds);


    @Modifying
    @Query(value = "update MenuModel set deleted = ?2 where pid = ?1")
    void deleteChildrenMenu(Long id, Integer deleted);
}
